<template>
  <div id="login">
    <el-form ref="user" :model="user" label-width="80px" style="width:30%;margin:20px auto;">
      <el-form-item label="登录账号">
        <el-input v-model="user.userName"></el-input>
      </el-form-item>
      <el-form-item label="登录密码">
        <el-input type="password" v-model="user.userPwd"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
    <p style="text-align:center;">默认账户admin密码：123321</p>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      user: {
        userName: "",
        userPwd: "",
      },
      base_url: process.env.VUE_APP_BASEURL,
    };
  },
  methods: {
    login() {
        axios.post(this.base_url + "/login", this.user).then((res) => {
            if(res.data.code == 2000){
                localStorage.setItem('token',res.data.data);
                this.$router.push('/');
            }
        });
    },
  },
};
</script>

<style>
</style>